AbstractAction.isSuccessResponse   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
import Twit from 'twit';
2
import Debug from 'debug';
3
import {BotConfig} from '..';
4
import Tweet from '../entities/Tweet';
5
6
export interface runArgs {
7
    onSuccess?: onSuccessType
8
}
9
10
type onSuccessType = (tweet: Tweet) => Promise<void>;
11
12 5
export abstract class AbstractAction {
13
    config: BotConfig;
14
    twit: Twit;
15
    debug: Debug.Debugger;
16
17
    constructor(config: BotConfig, twit: Twit, debug: Debug.Debugger) {
18 3
        this.config = config;
19 3
        this.twit = twit;
20 3
        this.debug = debug;
21
    }
22
23
    abstract run(args: runArgs): void;
24
25
    protected isSuccessResponse(response: Twit.PromiseResponse): boolean {
26 8
        return response.resp.statusCode === 200;
27
    }
28
}